<!DOCTYPE html>
<html>
    
<head>
    <meta charset="UTF-8">
	<title>小鱼ADMIN</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
	<link rel="stylesheet" href="/public/static/css/font.css">
	<link rel="stylesheet" href="/public/static/css/bgadmin.css">
	<script type="text/javascript" src="/public/static/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="/public/static/lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="/public/static/js/bgadmin.js"></script>
	<script type="text/javascript" src="/public/static/js/jquery.form.js"></script>  
</head>

<body>
<div class="bg-body">
    <form  action="#" method="post" id="mainForm" class="layui-form">
        <div class="layui-form-item">
            <input type="hidden" id="id" name="id" value="{$id}">
            <div class="layui-inline">
              <label class="layui-form-label">条件：</label>
              <div class="layui-input-inline">
                <select name="symbol" id="symbol" lay-verify="" autocomplete="off" class="layui-input" lay-search="">
                    <option value="">请选择</option>  <!--请选择-->
                    <option value="=" selected> 等于 </option>
                    <option value="<"> 小于 </option>
                    <option value=">"> 大于 </option>
                </select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">数值：</label>
              <div class="layui-input-inline">
                <input type="text" name="num" id= "num" lay-verify="" autocomplete="off" class="layui-input">
              </div>
            </div>
        </div>

        {if condition="($id eq 'integral') or ($id eq 'age') or ($id eq 'last_call_time') or ($id eq 'last_order_time') or ($id eq 'order_num') or ($id eq 'sign_num')"}
        <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label"></label>
              <div class="layui-input-inline">
                <input type="radio" name="relationship" id= "and" value="and" title="且" lay-verify="" checked autocomplete="off" class="layui-input">
                <input type="radio" name="relationship" id= "or" value="or" title="或" lay-verify="" autocomplete="off" class="layui-input">
              </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">条件：</label>
              <div class="layui-input-inline">
                <select name="symbol2" id="symbol2" lay-verify="" autocomplete="off" class="layui-input" lay-search="">
                    <option value="">请选择</option>  <!--请选择-->
                    <option value="=" selected> 等于 </option>
                    <option value="<"> 小于 </option>
                    <option value=">"> 大于 </option>
                </select>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">数值：</label>
              <div class="layui-input-inline">
                <input type="text" name="num2" id= "num2" lay-verify="" autocomplete="off" class="layui-input">
              </div>
            </div>
        </div>
        {/if}
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <a class="layui-btn" lay-submit=""  id="save" lay-filter="save">确定</a>
                </div>
            </div>
        </div>
    </form>
</div>
</body>
<!-- <script type="text/javascript" src="/public/static/crm/js/customer/shareCustomer.js"></script> -->
<script>

var layer = layui.layer;
var layedit = layui.layedit;

layui.use(['form', 'layedit'], function(){
    var form = layui.form
    ,layedit = layui.layedit;
    
    form.on('submit(save)', function(data){
        // $('#mainForm').ajaxSubmit(ajax_option);
        var id = $('#id').val();

        var symbol = $('#symbol').val();
        var num = $('#num').val();
        if ( !isNaN(parseInt(num)) && symbol) {
            var data = symbol+parseInt(num);
        } else {
            layer.alert('请填写有效条件', {icon: 5}, function(index){
                layer.close(index);
            });
            return false;
        }

        if (id == 'integral' || id == 'age' || id == 'order_num' || id == 'sign_num' ) {
            var symbol2 = $('#symbol2').val();
            var num2 = $('#num2').val();
            if ( !isNaN(parseInt(num2)) && symbol2) {
                var data2 = data;
                var relationship = $('input[name=relationship]:checked').val();
                data += ' '+ relationship +' '+id+' ' + symbol2 + parseInt(num2);

                data2 += relationship +' '+ symbol2 + parseInt(num2);
            } else {
                var data2 = data;
            }

            // alert(data);return false;
            parent.addSearchNum(id, data, data2);
            bg_admin_close();
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        } else if (id == 'last_call_time' || id == 'last_order_time') {
            var symbol2 = $('#symbol2').val();
            var num2 = $('#num2').val();
            if ( !isNaN(parseInt(num2)) && symbol2) {
                var data2 = data;
                var relationship = $('input[name=relationship]:checked').val();
                data += ','+ relationship +','+symbol2 + parseInt(num2);

                data2 += relationship +' '+ symbol2 + parseInt(num2);
            } else {
                var data2 = data;
            }
            // alert(data)
            parent.addSearchNum(id, data, data2);
            bg_admin_close();
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        }

        // alert(data);return false;
        parent.addSearchNum(id, data);
        bg_admin_close();
        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    }); 
});
</script>
</html>